package com.crazyread.dao;

import com.crazyread.model.domain.Authority;
import com.crazyread.model.domain.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    //查询所有用户
    @Select("select * from user order by id asc")
    public List<User> selectAllUser();
    
    //根据用户名查询用户信息
    @Select("SELECT * FROM user WHERE username=#{username}")
    public User selUserByUsername(String username);

    //根据权限id获取权限
    @Select("SELECT * FROM authority WHERE id=#{id}")
    public Authority selAuthorityById(Long id);

    //注册用户
    @Insert("INSERT INTO user (username,password,email,created) VALUES (#{username},#{password},#{email},#{created})")
    public void registerUser(User user);

    //修改密码
    @Update("update user set username=#{username},password=#{password},email=#{email} where id=#{id}")
    public void updateUser(User user);
    //删除用户
    @Delete("delete from user where id=#{id}")
    public void delUser(Integer id);



}
